/**
 * 
 */
package com.sy.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 孙阳
 *
 */
public class DateUtil {
	/**
	 * 
	 * @param date
	 * @param format
	 * @return
	 */
	public static String dateToString(Date date,String format){
		String temp=new String("");
		DateFormat df=new SimpleDateFormat(format);
		temp=df.format(date);
		return temp;
	}
	/**
	 * 
	 * @param oldDate
	 * @param oldStr
	 * @param format
	 * @return
	 */
	public static String oldToString(String oldDate,String oldStr,String format){
		String temp=new String("");
		DateFormat df=new SimpleDateFormat(oldStr);
		try {
			Date tdate=df.parse(oldDate);
			df=new SimpleDateFormat(format);
			temp=df.format(tdate);
		} catch (ParseException e) {
		}
		return temp;
	}
}
